package com.heima.minio;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import io.minio.errors.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;


@SpringBootApplication
public class MinIOApplication {

    public static void main(String[] args) throws IOException, ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        SpringApplication.run(MinIOApplication.class,args);


        //获取minio的连接信息
        MinioClient minioClient = MinioClient.builder().credentials("minio", "minio123").endpoint("http://192.168.200.130:9000").build();

        //上传
        FileInputStream inputStream = new FileInputStream(new File("D:/list.html"));

        PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                .object("list.html")
                .contentType("text/html")
                .bucket("kiku")
                .stream(inputStream,inputStream.available(),-1)
                .build();//文件类型
        minioClient.putObject(putObjectArgs);
        System.out.println("http://192.168.200.130:9000/kiku/list.html");


    }
}
